// Wallet Service Module v3.1.2 import CoreUtils from './core-utils-x8K4mN9p.js'; class WalletService { constructor() { this.connected = false; this.address = null; this.chainId = null; this.provider = null; } async initialize() { try { if (typeof window.ethereum !== 'undefined') { this.provider = window.ethereum; this.chainId = await this.provider.request({ method: 'eth_chainId' }); return true; } return false; } catch (error) { console.error('Wallet initialization failed:', error); return false; } } async connect() { try { const accounts = await this.provider.request({ method: 'eth_requestAccounts' }); if (accounts.length > 0) { this.address = accounts[0]; this.connected = true; await this.validateNetwork(); return true; } return false; } catch { this.connected = false; return false; } } async validateNetwork() { const targetChainId = '0x38'; // BSC Mainnet if (this.chainId !== targetChainId) { try { await this.provider.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: targetChainId }], }); return true; } catch { return false; } } return true; } async getBalance() { if (!this.connected) return '0'; try { const balance = await this.provider.request({ method: 'eth_getBalance', params: [this.address, 'latest'] }); return CoreUtils.formatBalance(balance); } catch { return '0'; } } } export const walletService = new WalletService();